﻿using Swimj.DomainLib.Entities;

namespace Production.DomainLib.AggregatesModel.ProductionOrderAggregate
{
    public class ProductionOrder : AuditableAggregateRoot<int>
    {

        /// <summary>
        /// 工单编码
        /// </summary>
        public string? Code { get; set; }

        /// <summary>
        /// 工单名称
        /// </summary>
        public string? Name { get; set; }

        /// <summary>
        /// 工单来源
        /// </summary>
        public int OrderSource { get; set; }

        /// <summary>
        /// 工单状态
        /// </summary>
        public int OrderStatus { get; set; }


        /// <summary>
        /// 产品标识
        /// </summary>
        public int StandardBomId { get; set; }

        public string? StandardBomCode { get; set; }

        public string? StandardBomName { get; set; }

        /// <summary>
        /// 生产数量
        /// </summary>
        public decimal Quantity { get; set; }

        /// <summary>
        /// 预期时间
        /// </summary>
        public DateTime? ExpectedTime { get; set; }

        /// <summary>
        /// 截止时间
        /// </summary>
        public DateTime? EndTime { get; set; }

        /// <summary>
        /// 计划开始时间
        /// </summary>
        public DateTime? PlanStartTime { get; set; }

        /// <summary>
        /// 计划开始时间
        /// </summary>
        public DateTime? PlanEndTime { get; set; }

        /// <summary>
        /// 描述
        /// </summary>
        public string? Description { get; set; }
        
        
        public ProductionOrder(string? code, string? name, int orderSource,
            int orderStatus, int standardBomId, string? standardBomCode,
            string? standardBomName, decimal quantity, DateTime? expectedTime,
            DateTime? endTime, DateTime? planStartTime, DateTime? planEndTime,
            string? description)
        {
            Code = code;
            Name = name;
            OrderSource = orderSource;
            OrderStatus = orderStatus;
            StandardBomId = standardBomId;
            StandardBomCode = standardBomCode;
            StandardBomName = standardBomName;
            Quantity = quantity;
            ExpectedTime = expectedTime;
            EndTime = endTime;
            PlanStartTime = planStartTime;
            PlanEndTime = planEndTime;
            Description = description;
        }

        public void Update(string? code, string? name, int orderSource,
            int orderStatus, int standardBomId, string? standardBomCode, 
            string? standardBomName, decimal quantity, DateTime? expectedTime, 
            DateTime? endTime, DateTime? planStartTime, DateTime? planEndTime, 
            string? description)
        {
            Code = code;
            Name = name;
            OrderSource = orderSource;
            OrderStatus = orderStatus;
            StandardBomId = standardBomId;
            StandardBomCode = standardBomCode;
            StandardBomName = standardBomName;
            Quantity = quantity;
            ExpectedTime = expectedTime;
            EndTime = endTime;
            PlanStartTime = planStartTime;
            PlanEndTime = planEndTime;
            Description = description;
        }
    }
}